﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
    <meta id="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
    <meta name="format-detection" content="telephone=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="icon" type="image/x-icon" href="./favicon.png" />
    <link rel="stylesheet" type="text/css" href="./js/vxe-table/style 3.6.9.css" />
    <title>服务管理</title>

    <style type="text/css">
        html,
        body {
            margin: 0 auto;
            font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", "微软雅黑", sans-serif;
            width: 100%;
            height: 100%;
        }

        #app {
            padding: 15px 10% 15px 10%;
            min-width: 600px;
            position: relative;
        }

        .tip {
            border-left: 4px solid #409eff;
            padding: 12px 24px 12px 30px;
            margin: 2em 0;
            background-color: #f8f8f8;
        }

        .divForm {
            margin-bottom: 24px;
            border: 1px solid #ebebeb;
            border-radius: 3px;
            transition: .2s;
            padding: 24px;
        }
    </style>
</head>
<body>
    <script type="text/javascript" src="./js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="./js/vue-2.6.10.min.js"></script>

    <script type="text/javascript" src="./js/vxe-table/xe-utils 3.5.7.js"></script>
    <script type="text/javascript" src="./js/vxe-table/vxe-table 3.6.9.js"></script>


    <div id="app">
        <div class="tip">
            Windows服务
        </div>
        <div class="divForm">
            <vxe-form>
                <vxe-form-item title="服务名" field="name" :item-render="{}">
                    <template #default>
                        <div>
                            {{WindowsService.WindowsServiceName}}
                        </div>
                    </template>
                </vxe-form-item>
            </vxe-form>

            <vxe-form>
                <vxe-form-item title="Windows服务状态" field="name" :item-render="{}">
                    <template #default="{ data }">
                        <div style="display:flex;">
                            <div v-show="WindowsService.IsWindowsInstall" style="background-color: green; padding: 0.2rem; color: white; display :flex; align-items:center;">
                                服务已安装
                            </div>
                            <div v-show="!WindowsService.IsWindowsInstall" style="background-color: red; padding: 0.2rem; color: white; display: flex; align-items: center;">
                                服务未安装
                            </div>

                            <div style="margin-left: 1rem;">
                                <vxe-button v-if="!WindowsService.IsWindowsInstall" @click="WindwsServiceInstall" href="javascript:" status="primary"> 安装服务</vxe-button>
                                <vxe-button v-if="WindowsService.IsWindowsInstall" @click="WindwsServiceUnInstall" href="javascript:" status="danger"> 卸载服务</vxe-button>
                            </div>
                        </div>
                    </template>
                </vxe-form-item>
            </vxe-form>

            <vxe-modal v-model="WindowsService.showWindwsServiceInstall">
                <template #title>
                    <span>安装Windows服务</span>
                </template>
                <template #corner>

                </template>
                <template #default>
                    <vxe-form>
                        <vxe-form-item title="服务名" field="name" span="24">
                            <template #default>
                                <vxe-input ref="modalInput" v-model="WindowsService.inputWindowsServiceName" placeholder="请输入服务名"></vxe-input>
                            </template>
                        </vxe-form-item>
                    </vxe-form>



                    <div class="vxe-modal--footer">
                        <button type="button" class="vxe-button type--button" @click="WindowsService.showWindwsServiceInstall=false">
                            <span class="vxe-button--content">取消</span>
                        </button>
                        <button type="button" class="vxe-button type--button theme--primary" @click="WindwsServiceInstallGo">
                            <span class="vxe-button--content">确认</span>
                        </button>
                    </div>
                </template>
            </vxe-modal>



        </div>
        <div class="divForm">
            <div class="tip">
                启动程序
            </div>
            <div style="padding-bottom:2rem;">
                <vxe-button status="success" content="新增" @click="ProgramAdd"></vxe-button>
            </div>
            <div>
                <vxe-table round
                           border
                           stripe
                           show-overflow
                           ref="xTable1" height="300" :row-config="{isCurrent: true, isHover: true}" :sort-config="{trigger: 'cell'}" :data="ProgramList">
                    <vxe-column type="seq" width="60"></vxe-column>
                    <!--<vxe-column field="ID" title="程序ID"></vxe-column>-->
                    <vxe-column field="FilePath" title="程序路径"></vxe-column>
                    <vxe-column field="Port" title="服务运行端口号"></vxe-column>
                    <vxe-column title="操作" fixed="right" width="200">
                        <template #default="row">
                            <vxe-button type="text" @click="ProgramUpdate(row)">修改</vxe-button>
                            <vxe-button type="text" @click="ProgramDelete(row)">删除</vxe-button>
                        </template>
                    </vxe-column>
                </vxe-table>
            </div>


            <vxe-modal v-model="ProgramInfo.ShowProgramInfo">
                <template #title>
                    <span>程序信息</span>
                </template>
                <template #corner>

                </template>
                <template #default>
                    <vxe-form>
                        <vxe-form-item title="程序路径" field="name" span="24">
                            <template #default>
                                <vxe-input v-model="ProgramInfo.FilePath" placeholder="请输入程序路径"></vxe-input>
                            </template>
                        </vxe-form-item>
                        <vxe-form-item title="程序端口" field="name" span="24">
                            <template #default>
                                <vxe-input v-model="ProgramInfo.Port" placeholder="请输入程序端口"></vxe-input>
                            </template>
                        </vxe-form-item>
                    </vxe-form>



                    <div class="vxe-modal--footer">
                        <button type="button" class="vxe-button type--button" @click="ProgramInfo.ShowProgramInfo=false">
                            <span class="vxe-button--content">取消</span>
                        </button>
                        <button type="button" class="vxe-button type--button theme--primary" @click="ProgramSave">
                            <span class="vxe-button--content">确认</span>
                        </button>
                    </div>
                </template>
            </vxe-modal>




        </div>


        <div class="divForm">
            <div class="tip">
                启动服务
            </div>
            <div style="padding-bottom:2rem;">
                <vxe-button status="success" content="新增" @click="ServiceAdd"></vxe-button>
            </div>
            <div>
                <vxe-table round
                           border
                           stripe
                           show-overflow
                           ref="xTable1" height="300" :row-config="{isCurrent: true, isHover: true}" :sort-config="{trigger: 'cell'}" :data="ServiceList">
                    <vxe-column type="seq" width="60"></vxe-column>
                    <!--<vxe-column field="ID" title="程序ID"></vxe-column>-->
                    <vxe-column field="ServiceName" title="服务名称"></vxe-column>
                    <vxe-column field="ServiceDescription" title="服务说明"></vxe-column>
                    <vxe-column field="FilePath" title="程序路径"></vxe-column>
                    <vxe-column field="Port" title="服务运行端口号"></vxe-column>
                    <vxe-column field="IsInstall" title="是否已安装"></vxe-column>
                    <vxe-column field="IsRun" title="是否已运行"></vxe-column>
                    <vxe-column title="操作" fixed="right" width="200">
                        <template #default="row">
                            <vxe-button v-if="!row.row.IsRun&&!row.row.IsInstall" type="text" status="danger" @click="ServiceDelete(row)">删除</vxe-button>
                            <vxe-button v-if="!row.row.IsInstall" type="text" status="primary" @click="ServiceInstall(row)">安装</vxe-button>
                            <vxe-button v-if="row.row.IsInstall&&!row.row.IsRun" type="text" status="success" @click="ServiceStart(row)">启动</vxe-button>
                            <vxe-button v-if="row.row.IsInstall&&row.row.IsRun" type="text" status="danger" @click="ServiceStop(row)">停止</vxe-button>
                            <vxe-button v-if="!row.row.IsRun&&row.row.IsInstall" type="text" status="danger" @click="ServiceUnInstall(row)">卸载</vxe-button>
                            <vxe-button v-if="!row.row.IsRun&&row.row.IsInstall" type="text" status="danger" @click="ServiceSVNUpdate(row)">更新</vxe-button>
                        </template>
                    </vxe-column>
                </vxe-table>
            </div>


            <vxe-modal v-model="ServiceInfo.ShowServiceInfo">
                <template #title>
                    <span>服务信息</span>
                </template>
                <template #corner>

                </template>
                <template #default>
                    <vxe-form>
                        <vxe-form-item title="服务名称" field="name" span="24">
                            <template #default>
                                <vxe-input v-model="ServiceInfo.ServiceName" placeholder="请输入服务名称"></vxe-input>
                            </template>
                        </vxe-form-item>
                        <vxe-form-item title="服务备注" field="name" span="24">
                            <template #default>
                                <vxe-input v-model="ServiceInfo.ServiceDescription" placeholder="请输入服务备注"></vxe-input>
                            </template>
                        </vxe-form-item>
                        <vxe-form-item title="程序路径" field="name" span="24">
                            <template #default>
                                <vxe-input v-model="ServiceInfo.FilePath" placeholder="请输入服务路径"></vxe-input>
                            </template>
                        </vxe-form-item>
                        <vxe-form-item title="服务端口" field="name" span="24">
                            <template #default>
                                <vxe-input v-model="ServiceInfo.Port" placeholder="请输入服务端口"></vxe-input>
                            </template>
                        </vxe-form-item>
                    </vxe-form>



                    <div class="vxe-modal--footer">
                        <button type="button" class="vxe-button type--button" @click="ServiceInfo.ShowServiceInfo=false">
                            <span class="vxe-button--content">取消</span>
                        </button>
                        <button type="button" class="vxe-button type--button theme--primary" @click="ServiceSave">
                            <span class="vxe-button--content">确认</span>
                        </button>
                    </div>
                </template>
            </vxe-modal>




        </div>




    </div>



    <script>
        $(function () {
            jQuery.support.cors = true;

            var Service = "";


            var vm = new Vue({
                el: '#app',
                data: function () {
                    return {
                        WindowsService: {
                            WindowsServiceName: "",//WindowsServiceName
                            IsWindowsInstall: false,//是否已安装为Windos服务
                            showWindwsServiceInstall: false,//是否显示安装服务提示框
                            inputWindowsServiceName: "",//输入的Windows服务名称
                        },
                        ProgramList: [],//程序列表
                        ProgramInfo: {
                            OpenType: 0,//操作类型  1，添加 2，修改
                            ShowProgramInfo: false,//是否显示程序信息框
                            ID: "",
                            FilePath: "",//程序路径
                            Port: 0,//端口号
                        },
                        ServiceList: [],//程序列表
                        ServiceInfo: {
                            OpenType: 0,//操作类型  1，添加 2，修改
                            ShowServiceInfo: false,//是否显示程序信息框
                            ID: "",
                            ServiceName: "",//服务名称
                            ServiceDescription: "",//服务备注
                            FilePath: "",//程序路径
                            Port: 0,//端口号
                        }

                    }
                },
                components: {},
                created: function () {

                },
                mounted: function () {
                    window.vm = this;
                },
                computed: {

                },
                methods: {
                    WindwsServiceInstall() {
                        //显示安装服务信息
                        this.WindowsService.inputWindowsServiceName = this.WindowsService.WindowsServiceName;
                        this.WindowsService.showWindwsServiceInstall = true;
                        this.$refs.modalInput.focus();

                    },
                    WindwsServiceInstallGo() {
                        //安装windows服务
                        this.WindowsService.showWindwsServiceInstall = false;
                        $.ajax({
                            type: "post",
                            url: Service + "/api/WindowsService/WindowsServiceInstall",
                            data: {
                                ParamStr: JSON.stringify({
                                    ServiceName: this.WindowsService.inputWindowsServiceName
                                })
                            },
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 1) {
                                    vm.WindowsService.IsWindowsInstall = true;
                                    vm.WindowsService.WindowsServiceName = vm.WindowsService.inputWindowsServiceName;
                                    vm.WindowsService.showWindwsServiceInstall = false;
                                    setTimeout(vm.IsWindowsServiceExists(), 2000);
                                }

                            },
                            error: function (data) {
                                setTimeout(vm.IsWindowsServiceExists(), 2000);
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                    WindwsServiceUnInstall() {
                        //删除windows服务
                        VXETable.modal.confirm('确定要删除Windows服务吗？').then(type => {
                            if (type == "confirm") {
                                vm.WindowsService.IsWindowsInstall = false;
                                $.ajax({
                                    type: "post",
                                    url: Service + "/api/WindowsService/WindowsServiceUnInstall",
                                    data: {
                                    },
                                    async: true, //同步请求
                                    timeout: 10000, //超时时间设置，单位毫秒
                                    dataType: 'json',
                                    crossDomain: true,
                                    success: function (data) {
                                        if (data.Success === 1) {
                                            vm.WindowsService.IsWindowsInstall = false;
                                        }
                                        setTimeout(vm.IsWindowsServiceExists(), 2000);
                                    },
                                    error: function (data) {
                                        setTimeout(vm.IsWindowsServiceExists(), 2000);
                                        console.log('服务器执行失败' + data.responseText);
                                    }
                                });
                            }
                        })
                    },
                    GetWindowsServiceName() {
                        //获取系统服务名
                        $.ajax({
                            type: "post",
                            url: Service + "/api/WindowsService/GetWindowsServiceName",
                            data: {},
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 1) {
                                    vm.WindowsService.WindowsServiceName = data.Result;
                                    vm.IsWindowsServiceExists();
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    IsWindowsServiceExists() {
                        //Windows服务是否存在
                        $.ajax({
                            type: "post",
                            url: Service + "/api/WindowsService/IsWindowsServiceExists",
                            data: {},
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 1) {
                                    vm.WindowsService.IsWindowsInstall = data.Result;
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    ProgramListGet() {
                        //获取程序列表
                        $.ajax({
                            type: "post",
                            url: Service + "/api/Program/ProgramListGet",
                            data: {},
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -2) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    vm.ProgramList = data.Result;

                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    ProgramAdd() {
                        //增加需要管理的程序
                        vm.ProgramInfo.ShowProgramInfo = true;
                        vm.ProgramInfo.OpenType = 1;
                        vm.ProgramInfo.ID = 0;
                        vm.ProgramInfo.FilePath = "";
                        vm.ProgramInfo.Port = 0;

                    },
                    ProgramUpdate(row) {
                        console.log(row)
                        //更新需要管理的程序
                        vm.ProgramInfo.ShowProgramInfo = true;
                        vm.ProgramInfo.OpenType = 2;
                        vm.ProgramInfo.ID = row.row.ID;
                        vm.ProgramInfo.FilePath = row.row.FilePath;
                        vm.ProgramInfo.Port = row.row.Port;
                    },
                    ProgramSave() {
                        let _param = {
                            ID: vm.ProgramInfo.ID,
                            FilePath: vm.ProgramInfo.FilePath,
                            Port: vm.ProgramInfo.Port,
                        };
                        if (vm.ProgramInfo.OpenType == 1) {
                            //添加需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Program/ProgramAdd",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {

                                        vm.ProgramListGet();
                                        vm.ProgramInfo.ShowProgramInfo = false;
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }
                        else {
                            //添加需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Program/ProgramUpdate",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 1) {

                                        vm.ProgramListGet();
                                        vm.ProgramInfo.ShowProgramInfo = false;
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }

                    },
                    async ProgramDelete(row) {
                        const type = await VXETable.modal.confirm('您确定要删除吗？')
                        if (type == "confirm") {
                            let _param = {
                                ID: row.row.ID
                            };
                            //删除需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Program/ProgramDelete",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 1) {
                                        vm.ProgramListGet();
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }


                    },

                    ServiceListGet() {
                        //获取程序列表
                        $.ajax({
                            type: "post",
                            url: Service + "/api/Service/ServiceListGet",
                            data: {},
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -2) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    vm.ServiceList = data.Result;

                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    ServiceAdd() {
                        //增加需要管理的程序
                        vm.ServiceInfo.ShowServiceInfo = true;
                        vm.ServiceInfo.OpenType = 1;
                        vm.ServiceInfo.ID = 0;
                        vm.ServiceInfo.ServiceName = "";
                        vm.ServiceInfo.ServiceDescription = "";
                        vm.ServiceInfo.FilePath = "";
                        vm.ServiceInfo.Port = 0;

                    },
                    ServiceUpdate(row) {
                        console.log(row)
                        //更新需要管理的程序
                        vm.ServiceInfo.ShowServiceInfo = true;
                        vm.ServiceInfo.OpenType = 2;
                        vm.ServiceInfo.ID = row.row.ID;
                        vm.ServiceInfo.ServiceName = "";
                        vm.ServiceInfo.ServiceDescription = "";
                        vm.ServiceInfo.FilePath = row.row.FilePath;
                        vm.ServiceInfo.Port = row.row.Port;
                    },
                    ServiceSave() {
                        let _param = {
                            ID: vm.ServiceInfo.ID,
                            ServiceName: vm.ServiceInfo.ServiceName,
                            ServiceDescription: vm.ServiceInfo.ServiceDescription,
                            FilePath: vm.ServiceInfo.FilePath,
                            Port: vm.ServiceInfo.Port,
                        };
                        if (vm.ServiceInfo.OpenType == 1) {
                            //添加需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceAdd",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {

                                        vm.ServiceListGet();
                                        vm.ServiceInfo.ShowServiceInfo = false;
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }
                        else {
                            //添加需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceUpdate",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 1) {

                                        vm.ServiceListGet();
                                        vm.ServiceInfo.ShowServiceInfo = false;
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }

                    },
                    async ServiceDelete(row) {
                        const type = await VXETable.modal.confirm('您确定要删除吗？')
                        if (type == "confirm") {
                            let _param = {
                                ID: row.row.ID
                            };
                            //删除需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceDelete",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        vm.ServiceListGet();
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }


                    },

                    async ServiceInstall(row) {
                        const type = await VXETable.modal.confirm('您确定要安装服务吗？')
                        if (type == "confirm") {
                            let _param = {
                                ID: row.row.ID
                            };
                            //删除需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceInstall",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        vm.ServiceListGet();
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }


                    },
                    async ServiceUnInstall(row) {
                        const type = await VXETable.modal.confirm('您确定要安装服务吗？')
                        if (type == "confirm") {
                            let _param = {
                                ID: row.row.ID
                            };
                            //删除需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceUnInstall",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        vm.ServiceListGet();
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }

                    },
                    async ServiceStart(row) {
                        const type = await VXETable.modal.confirm('您确定要启动务吗？')
                        if (type == "confirm") {
                            let _param = {
                                ID: row.row.ID
                            };
                            //删除需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceStart",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        vm.ServiceListGet();
                                    }
                                    else {

                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }


                    },
                    async ServiceStop(row) {
                        const type = await VXETable.modal.confirm('您确定要停止服务吗？')
                        if (type == "confirm") {
                            let _param = {
                                ID: row.row.ID
                            };
                            //删除需要管理的程序
                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceStop",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        vm.ServiceListGet();
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }


                    },
                    async ServiceSVNUpdate(row) {
                        //更新服务
                        const type = await VXETable.modal.confirm('您确定要更新服务吗？')
                        if (type == "confirm") {
                            let _param = {
                                ID: row.row.ID
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/Service/ServiceSVNUpdate",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -2) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        vm.ServiceListGet();
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }


                    },



                }
            })

            vm.GetWindowsServiceName();
            vm.ProgramListGet();
            vm.ServiceListGet();

        });

    </script>
</body>
</html>
